package com.iss.demo.dao;

import com.iss.demo.entity.ShopCar;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ShopCarDao {
    @Select("select * from shopcar where u_id=#{u_id};")
    public List<ShopCar> selectAllById(Integer u_id);

    @Select("select count(*) from shopcar where u_id=#{u_id};")
    public Integer selectCountById(Integer u_id);

    @Insert("INSERT INTO shopcar (u_id,c_surface,c_name,c_dealer,c_fri_price,c_price) VALUES " +
            "(#{u_id},#{c_surface},#{c_name},#{c_dealer},#{c_fri_price},#{c_price});")
    public Integer insertShop(ShopCar shopCar);

    @Delete("delete from shopcar where c_id=#{c_id}")
    public Integer deleteShopCar(Integer c_id);

    @Delete("delete from shopcar where u_id=#{u_id}")
    public Integer deleteShopCarByUid(Integer u_id);
}
